﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SnakeGame
{
    class ConsoleRenderer
    {

        private char snakeHeadSign;
        private char snakeBodySign;
        private char foodSign;
        private char fieldSign;

        private Point food;
        private Snake snake;
        private GameOptions gameOptions;

        public ConsoleRenderer( char snakeHeadSign, 
                                char snakeBodySign, 
                                char foodSign,
                                char fieldSign,    
                                Point food, Snake snake, 
                                GameOptions gameOptions 
                              )
        {
            this.snakeHeadSign = snakeHeadSign;
            this.snakeBodySign = snakeBodySign;
            this.foodSign = foodSign;
            this.fieldSign = fieldSign;
            this.food = food;
            this.snake = snake;
            this.gameOptions = gameOptions;
        }

        public void RenderFood()
        {
            Console.SetCursorPosition(this.food.X, this.food.Y);
            Console.Write(this.foodSign);
        }

        public void RenderField(List<Point> line)
        {
            foreach (Point p in line)
            {
                Console.SetCursorPosition(p.X, p.Y);
                Console.Write(this.fieldSign);
            }
        }

        public void RenderSnake()
        {
            Console.SetCursorPosition(this.snake.Head.X, this.snake.Head.Y);
            Console.Write(this.snakeHeadSign);

            foreach (Point b in snake.Body)
            {
                Console.SetCursorPosition(b.X, b.Y);
                Console.Write(this.snakeBodySign);
            }
        }

        public void Clear()
        {
            Console.Clear();
        }



        public void ClearSnake(Snake snake, Point food)
        {
            List<Point> forClear = new List<Point>();
            forClear.Add(food);
            forClear.Add(snake.Head);
            forClear.AddRange(snake.Body);

            foreach (Point p in forClear)
            {
                Console.SetCursorPosition(p.X, p.Y);
                Console.Write(' ');
            }
        }
    }

}
